package workers;

import java.util.concurrent.BlockingQueue;

import model.Software;
import workerUIs.StepFrame;
import workflow.IEventListener;
import workflow.WorkflowEvent;
import workflow.WorkflowEvent.EventType;
import workflow.step.ReleaseStep;

public class ReleaseStepWorker extends AbstractStepSwingWorker {

	public ReleaseStepWorker(StepFrame frame,
			BlockingQueue<Software> inputQueue, final IEventListener listener) {
		super(frame, inputQueue, null, null, listener);
	}

	@Override
	protected Software doInBackground() throws Exception {
		this.software = this.inputQueue.take();
		if (listener != null) listener.onEvent(WorkflowEvent.createEvent(this.software.getId(), getTaskName(), EventType.START));
		Thread.sleep(delay);
		doStep(software);
		if (listener != null) listener.onEvent(WorkflowEvent.createEvent(this.software.getId(), getTaskName(), EventType.END));
		return this.software;
	}
	
	@Override
	protected Software doStep(Software software) {
		return new ReleaseStep().doStep(software);
	}

	@Override
	protected String getTaskName() {
		return "release";
	}

}
